package allenja.cp2011.MVC;

import java.util.logging.Logger;

public aspect ChatServerAspect {
	private final Logger logger;
	
	// Create the global logger
	public ChatServerAspect() {
		logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
	}
	
	// Pointcut for the creation of the chat users table in the derby database
	pointcut createChatUsersTable() : call (void DerbyJdbcDAO.createChatUsersTable());
	
	// Log the chat users table setup BEFORE
	before() : createChatUsersTable() {
		logger.info("About to call createChatUsersTable()...");
	}	
	
	// Log the chat users table setup AFTER
	after() : createChatUsersTable() {
		logger.info("Finished createChatUsersTable()...");
	}
	
	// Pointcut for the creation of the forum repository table in the derby database
	pointcut createForumTable() : call (void DerbyJdbcDAO.createForumTable());
	
	// Log the forum repository table setup BEFORE
	before() : createForumTable() {
		logger.info("About to call createForumTable()...");
	}
	
	// Log the forum repository table setup AFTER
	after() : createForumTable() {
		logger.info("Finished createForumTable()...");
	}
	
	// Pointcut for the creation of the forum messages table in the derby database
	pointcut createForumMessagesTable() : call (void DerbyJdbcDAO.createForumMessagesTable());
	
	// Log the forum messages table setup BEFORE
	before() : createForumMessagesTable() {
		logger.info("About to call createForumMessagesTable()...");
	}
	
	// Log the forum messages table setup AFTER
	after() : createForumMessagesTable() {
		logger.info("Finished createForumMessagesTable()...");
	}
	
	// Pointcut for the inner join of the forum repository table to the forum messages table in the derby database
	pointcut createForumTableToForumMessagesTableJoin() : call (void DerbyJdbcDAO.createForumTableToForumMessagesTableJoin());
	
	// Log the inner join setup BEFORE
	before() : createForumTableToForumMessagesTableJoin() {
		logger.info("About to call createForumTableToForumMessagesTableJoin()...");
	}
	
	// Log the inner join setup AFTER
	after() : createForumTableToForumMessagesTableJoin() {
		logger.info("Finished createForumTableToForumMessagesTableJoin()...");
	}
}
